import rclpy
from rclpy.node import Node
from std_msgs.msg import String


class HelloPub(Node):
    def __init__(self):
        super().__init__("hello_pub")
        self.publisher_ = self.create_publisher(String, "/hello", 10)
        self.timer = self.create_timer(1.0, self.timer_callback)
        self.count = 0

    def timer_callback(self):
        msg = String()
        self.count += 1
        msg.data = f"hello world {self.count}"
        self.publisher_.publish(msg)
        self.get_logger().info(f'Publishing: "{msg.data}"')


def main(args=None):
    rclpy.init(args=args)
    node = HelloPub()
    rclpy.spin(node)
    node.destroy_node()
    rclpy.shutdown()
